<?php
// 本类由系统自动生成，仅供测试用途
namespace Admin\Controller;
use Think\Controller;
class IndexController extends baseActionController {
    public function index(){

    	$this->yuand();
    	
    	$name=$_SESSION['name'];
    	
    	$this->assign('name',$name);// 赋值分页输出
    	
    	$this->display();
    }
    public function welcome(){
    	$this->display();
    }
    public function login(){
    	$this->display();
    }
  
    public function verify(){
    	 
    	$config =    array(
    			'fontSize'    =>    18,    // 验证码字体大小
    			'length'      =>    3,     // 验证码位数
    			'useNoise'    =>    false,// 关闭验证码杂点
    			'imageH'    =>   38,
    			'imageW'    =>   100,
    	);
    	$Verify = new \Think\Verify($config);
    	$Verify->entry();
    }
    private  function thumb($cimg,$nimg,$size){
    	$image = new \Think\Image();
    	$image->open($cimg);
    	// 按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.jpg
    	$image->thumb($size,$size)->save($nimg);
    }
    
    
public function dologin(){
    	//验证
    	$verify = new \Think\Verify();
    	
    	$into=$verify->check(I('post.verify'));
    	if (!$into) {
    		$this->error('验证错误','login',5);
    	}
    	//查询
    	
    	$date['apwd']=md5(I('post.pwd'));
    	$date['aname']=I('post.uname');
    
    	$rel=M('Admin')->where($date)->find();
    	
    	if ($rel) {
    		session('name',$rel['niname']);
    		session('id',$rel['aid']);
    		
    		$this->success('登陆成功',U('index'));
    	}else {
    		$this->error('登陆失败');
    	}
    	 	
    }
    public function loginout(){
    	session('name',null); // 删除name
    	session('id',null); // 删除name
    	 
    	$this->success('注销成功','login');
    }
}